﻿using UnityEngine;
using UnityEngine.Events;

public class SpeedCheckCollection : MonoBehaviour
{
    public UnityEvent OnAllCheckPass;
    public SpeedCheck[] SpeedChecks;
    private void Awake()
    {
        foreach (var item in SpeedChecks)
        {
            item.OnSpeedPass.AddListener(Check);
        }
    }

    void Check()
    {
        foreach (var item in SpeedChecks)
        {
            if (!item.IsPass)
                return;
        }
        OnAllCheckPass.Invoke();
    }

    public void ResetSpeedCheck()
    {
        foreach (var item in SpeedChecks)
        {
            item.enabled = true;
            item.ResetColor();
            item.IsPass = false;
        }
    }
}
